package com.daxia.ogmall.web.controller;

import java.util.Date;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.daxia.ogmall.dto.GzActivityDTO;
import com.daxia.ogmall.service.SqlService;

/**
 * 2017年3月16号广州展会报名
 * @author kevin
 *
 */
@Controller
@RequestMapping("gzActivity")
public class GzActivityController extends BaseController {
	@Autowired
	private SqlService sqlService;
	
	@RequestMapping("index")
	public String index(Map<String, Object> map) throws Exception {
		int count = gzActivityService.count();
		map.put("count", 12058 + count);
		return "gzActivity/gzActivity_index";
	}
	
	@ResponseBody
	@RequestMapping("apply")
	public String apply(String mobile, String name) throws Exception {
		if (StringUtils.isBlank(mobile)) {
			throw new RuntimeException("请输入电话");
		}
		if (StringUtils.isBlank(name)) {
			throw new RuntimeException("请输入手机姓名");
		}
		
		GzActivityDTO dto = new GzActivityDTO();
		dto.setMobile(mobile);
		dto.setName(name);
		dto.setTime(new Date());
		gzActivityService.create(dto);
		return ok();
	}
}	